<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>layout 登录 - Layui</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
    <style>
        #logo{font-size:19px; margin-left: 130px;margin-left: 200px;}
        #logo:link{color:#009688;}
        #logo:hover {color:#4E5465}
        .cr-body {
            margin: 15px auto 48px auto;
            max-width: 780px;
        }
        .cr-body h1 {
            font-size: 22px;
            margin-bottom: 10px;
            line-height: 30px;
            padding: 10px;
            color: #393D49;
            border-bottom: 1px solid #009688;
        }
        .cr-form {
            margin: 15px auto;
            max-width: 480px;
            background-color: #fff;
            padding: 30px;
            border: 1px solid #f0f0f0;
        }
        .cr-form a {
            color: #999;
            text-decoration: underline;
        }
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo" id="logo">CRM客户关系管理系统</div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item" style="margin-right:200px;">
                <a href="#">
                    登录
                </a>
            </li>
        </ul>
    </div>
    <div class="cr-body">

        <h1><i class="layui-icon"></i> 用户登录</h1>
        <div class="cr-form">
            <%--             action="http://crm.bigpeng.cn:80/user/login" --%>
            <form class="layui-form" style="margin-left: 30px;" lay-filter="loginForm" action="${pageContext.request.contextPath}/go" id="submitForm"  method="post">
                <!--<i class="layui-icon">&#xe613;</i>
                  <hr>-->
                <div class="layui-form-item">
                    <label class="layui-form-label">登录帐号</label>
                    <div class="layui-input-block" style="width: 250px;">
                        <input name="account" type="text" lay-verify="required" placeholder="登录帐号(必填)" autocomplete="off" class="layui-input">

                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">登录密码</label>
                    <div class="layui-input-inline" style="width: 250px;">
                        <input name="password"  type="password" lay-verify="required" placeholder="登录密码(必填)" autocomplete="off" class="layui-input">

                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">验证码</label>
                    <div class="layui-input-block"  >
                        <input type="text" name="check" placeholder="验证码(必填)" autocomplete="off" class="layui-input" style="width: 100px; float: left; margin-right: 14px">
                        <img src="checkCode" height="32px" alt="" onclick="changeCheckCode(this)" id="img">
                    </div>
                </div>
                <%--<input type="text" id="check" name="check" class="check">--%>
                <!--checkCode?-->
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <%--<input type="submit" value="提交" class="layui-btn layui-btn-default">--%>
                        <button  style="margin-top: 10px;" class="layui-btn layui-btn-default" id="loginButton" lay-submit lay-filter="loginForm">
                        <i class="layui-icon">စ</i>&nbsp;登录系统
                        </button>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label" ></label>
                    <div>
                        <a  href="http://crm.bigpeng.cn:80/pages/forgotPasswd.jsp">忘记密码</a>
                    </div>
                </div>
            </form>

        </div>


    </div>

</div>
<script type="text/javascript">
    //图片点击事件
    function changeCheckCode(img) {
        img.src = "checkCode?" + new Date().getTime();
    }
</script>
<script src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
<script>
    //JavaScript代码区域
    layui.use(['layer', 'form','jquery'], function () {
        var layer = layui.layer//layer 弹窗对象
            , form = layui.form;//表单对象
        var $=layui.$;

        layer.msg('Hello World')
        form.on("submit(loginForm)",function (data) {
            $.post("${pageContext.request.contextPath}/go",data.field,function (result) {
                if(result.code==0){
                    layer.msg("登录成功")
                    //刷新父窗口的表格
                    window.location.href="/index.jsp";
                    //关闭本窗口
                    //当你在iframe页面关闭自身时
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                }else if(result.code==1){
                    layer.msg("验证码错误")
                    $("#img").attr({ src: "checkCode?" + new Date().getTime() });
                }else if(result.code==2){
                    layer.msg("账号密码错误")
                    $("#img").attr({ src: "checkCode?" + new Date().getTime() });
                }
            },"json")
            return false;
        })

    })
</script>
</body>
</html>